<template lang="pug">
view.has-page-bgcolor.mod
  view.radius.bg.white.mod.unbt
    view.flex
      view 手机号
      input.grow.mod.unr.right(placeholder-class="placeholder" placeholder="请输入新手机号码" maxlength="11" type="number" v-model="data.phone")
    view.flex.captcha
      view 验证码
      input.grow.mod.right.m-r-25(placeholder-class="placeholder" placeholder="请输入验证码" maxlength="6" type="number"  v-model="data.code")
      view.txt.red.mod.unr(@click="methods._captcha") {{ Number.isInteger(data.captchaBtn)? (data.captchaBtn+'秒重发'): '获取验证码' }}
  view.btn.round(@click="methods._submit") 提交
</template>
<script setup>
import {reactive} from 'vue'
//import {home} from '/common/config/url.json'
//import {__get} from '/common/script/req.promise'
import {_tip, _go, _feedback} from '/common/script/tip'
//import {onLoad} from '@dcloudio/uni-app'

const data = reactive({
  form: {
    phone: '',
    code: ''
  },
  captchaBtn: ''
})
const methods = {
  _captcha(){
    const {form: {phone}, captchaBtn} = data

    if(Number.isInteger(captchaBtn)) return false
    const downer = ()=>{
      data.captchaBtn = 60
      const siv = setInterval(()=>{
        data.captchaBtn--
        if(!form.captchaBtn){
          clearInterval(siv)
          data.captchaBtn = ''
        }
      }, 1000)
    }

    if(_feedback(phone, '请正确输入手机号', 'mobile')){
      //Type: 1注册，2重置密码 3登录 4下单，5设置手机号
      __post(baseApi.sendSMS, {phone, Type: 5}).then(downer)
      // downer()
    }
  },
  _commit(){
    const {phone, code} = data.form
    if(_feedback(phone, '请正确输入手机号', 'mobile') && _feedback(code.length < 4, '请正确输入验证码')){
      
    }
  }
}
</script>
<style lang="scss" scoped>
.has-page-bgcolor{
  --btn-margin-top: 45rpx;
  .captcha{
    border-top: 1px solid #EBEBEB;
  }
}
</style>